package main;

import javax.servlet.http.HttpServletRequest;

public class UserAgentHelper {
    public static boolean isCrawlFromRequestInfo(HttpServletRequest request) {
        //TODO: 开启机器人检测
//        String referer = request.getHeader("referer");
//        String browserName = request.getHeader("User-Agent");
//
//        String siteUrl = UriHelper.getServerBaseUri(request);
//        String referUrl = UriHelper.getBaseUriFromString(referer);
//        boolean result = false;
//        if (referer == null || referer.isEmpty() || !referUrl.equals(siteUrl)
//        || browserName == null || browserName.isEmpty()) {
//            result = true;
//        }
//        return result;
        return false;
    }

    public static String getUserAgent(HttpServletRequest request) {
        return request.getHeader("User-Agent");
    }
}
